<template>
    <div class="box">
        <div class="title">
            <p>年龄比例</p>
            <img src="@/assets/screen/dataScreen-title.png" alt="">
        </div>
        <div class="charts" ref="chart"></div>
    </div>
</template>

<script setup lang='ts'>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

const chart = ref()

onMounted(() => {
    const mycharts = echarts.init(chart.value,null, {
    height: 240
  })
    const option = {
        tooltip: {
            trigger: 'item'
        },
        legend: {
            top: '40',
            right: '30',
            orient:'vertical',
            textStyle:{
                color:'white',
            }
        },
        series: [
            {
                name: 'Age',
                type: 'pie',
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                itemStyle: {
                    borderRadius: 10,
                    borderColor: '#fff',
                    borderWidth: 2
                },
                label: {
                    show: true,
                    position: 'inside',
                },
                labelLine: {
                    show: false
                },
                data: [
                    { value: 1048, name: '0-20' },
                    { value: 735, name: '21-35' },
                    { value: 580, name: '36-45' },
                    { value: 484, name: '46-55' },
                    { value: 300, name: '55-65' },
                    { value: 250, name: '66-85' }
                ]
            }
        ],
        grid:{
            left:0,
            right:0,
            top:0,
            bottom:0
        }
    };
    mycharts.setOption(option)
})
</script>

<style scoped lang="scss">
.box {
    width: 100%;
    height: 100%;
    background: url(@/assets/screen/dataScreen-main-cb.png) no-repeat;
    background-size: 100% 100%;
    margin-top: 20px;
    margin-bottom:10px;

    .title {
        p {
            color: white;
            font-size: 20px
        }
    }

    .charts {
        height: 200px;
    }
}
</style>